package compilerAPI;

import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;
import java.io.File;

/**
 * @Author: webmaster@pavel-kaminsky.com
 * @Date: 01/09/11
 */
public class CompilerAPi {
    public static void main(String[] args) {

        String fileToCompile = new File("src/compilerAPI") + java.io.File.separator + FredDurst.class.getSimpleName()+".java";
        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
        int compilationResult = compiler.run(null, null, null, fileToCompile);

        if (compilationResult == 0)

            System.out.println("Compilation is successful");
        else
            System.out.println("Compilation Failed");

    }
}
